package com.ruoyi.web.controller.laiqianba.merchant;

import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.db.domain.MerchantDataNoticeLog;
import com.ruoyi.web.wrapper.MerchantDataNoticeLogWrapper;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.merchant.service.IMerchantDataNoticeLogService;

/**
 * 商户回调通知日录Controller
 * 
 * @author ruoyi
 * @date 2023-12-09
 */
@RestController
@RequestMapping("/merchant/notice")
public class MerchantDataNoticeLogController extends BaseController
{
    @Autowired
    private IMerchantDataNoticeLogService merchantDataNoticeLogService;

    /**
     * 查询商户回调通知日录列表
     */
    @PreAuthorize("@ss.hasPermi('merchant:notice:list')")
    @GetMapping("/list")
    public TableDataInfo list(MerchantDataNoticeLog merchantDataNoticeLog)
    {
        startPage();
        List<Map<String, Object>> list = merchantDataNoticeLogService.selectMerchantDataNoticeLogMapList(merchantDataNoticeLog);
        list = new MerchantDataNoticeLogWrapper(list).wrap();
        return getDataTable(list);
    }

    /**
     * 导出商户回调通知日录列表
     */
    @PreAuthorize("@ss.hasPermi('merchant:notice:export')")
    @Log(title = "商户回调通知日录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MerchantDataNoticeLog merchantDataNoticeLog)
    {
        List<MerchantDataNoticeLog> list = merchantDataNoticeLogService.selectMerchantDataNoticeLogList(merchantDataNoticeLog);
        ExcelUtil<MerchantDataNoticeLog> util = new ExcelUtil<MerchantDataNoticeLog>(MerchantDataNoticeLog.class);
        util.exportExcel(response, list, "商户回调通知日录数据");
    }

    /**
     * 获取商户回调通知日录详细信息
     */
    @PreAuthorize("@ss.hasPermi('merchant:notice:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(merchantDataNoticeLogService.selectMerchantDataNoticeLogById(id));
    }

    /**
     * 新增商户回调通知日录
     */
    @PreAuthorize("@ss.hasPermi('merchant:notice:add')")
    @Log(title = "商户回调通知日录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MerchantDataNoticeLog merchantDataNoticeLog)
    {
        return toAjax(merchantDataNoticeLogService.insertMerchantDataNoticeLog(merchantDataNoticeLog));
    }

    /**
     * 修改商户回调通知日录
     */
    @PreAuthorize("@ss.hasPermi('merchant:notice:edit')")
    @Log(title = "商户回调通知日录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MerchantDataNoticeLog merchantDataNoticeLog)
    {
        return toAjax(merchantDataNoticeLogService.updateMerchantDataNoticeLog(merchantDataNoticeLog));
    }

    /**
     * 删除商户回调通知日录
     */
    @PreAuthorize("@ss.hasPermi('merchant:notice:remove')")
    @Log(title = "商户回调通知日录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(merchantDataNoticeLogService.deleteMerchantDataNoticeLogByIds(ids));
    }
}
